<html>
<title>涨停表现</title>
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='css/fupan_css.css') }}" />
<script src="{{ url_for('static',filename='js/jquery-2.1.1.min.js') }}"></script>
<script src="{{ url_for('static',filename='js/show_message.js') }}"></script>
<script src="{{ url_for('static',filename='js/update.js') }}"></script>
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">

<body>
    <div class="table-one" style="float:left;width:300px;height:900px;overflow:auto;">
        <table id="limit1" cellspacing="0"></table>
    </div>
    <div class="table-one" style="float:left;width:300px;height:800px;" >
        <div class="table-one" style="float:left;width:300px;height:300px;overflow:auto;" >
            <table id="limit2" cellspacing="0"></table>
        </div>
        <div class="table-one" style="float:left;width:300px;height:600px;overflow:auto;" >
            <table id="limit22" cellspacing="0"></table>
        </div>
    </div>
    <div class="table-one" style="float:left;width:300px;height:800px;" >
        <div class="table-one" style="float:left;width:300px;height:300px;overflow:auto;" >
            <table id="limit3" cellspacing="0"></table>
        </div>
        <div class="table-one" style="float:left;width:300px;height:600px;overflow:auto;" >
            <table id="limit33" cellspacing="0"></table>
        </div>
    </div>
    <div class="table-one" style="float:left;width:300px;height:800px;" >
        <div class="table-one" style="float:left;width:300px;height:300px;overflow:auto;" >
            <table id="limit4" cellspacing="0"></table>
        </div>
        <div class="table-one" style="float:left;width:300px;height:600px;overflow:auto;" >
            <table id="limit44" cellspacing="0"></table>
        </div>
    </div>
    <div class="table-one" style="float:left;width:300px;height:800px;" >
        <div class="table-one" style="float:left;width:300px;height:300px;overflow:auto;" >
            <table id="limit5" cellspacing="0"></table>
        </div>
        <div class="table-one" style="float:left;width:300px;height:600px;overflow:auto;" >
            <table id="limit55" cellspacing="0"></table>
        </div>
    </div>
</body>

<script type="text/javascript">
    var ID_THREAD = -1; //循环线程
    var all_theme = []; //题材数组
    
    $(document).ready(function() {
        get_limit1_data('get_daily_limit_performance','1', 'limit1','一板')
        get_limit1_data('get_daily_limit_performance','2', 'limit2','二板')
        get_limit2_data('get_daily_limit_performance2','2', 'limit22','未涨停的昨日一板个股')
        get_limit1_data('threePlate','2', 'limit3','三板')
        get_limit2_data('twoBoardStocksYesterday','2', 'limit33','未涨停的昨日二板个股')
        get_limit1_data('fourPlate','2', 'limit4','四板')
        get_limit2_data('threeBoardStocksYesterday','2', 'limit44','未涨停的昨日三板个股')
        get_limit1_data('fivePlate','2', 'limit5','更高')
        get_limit2_data('fourBoardStocksYesterday','2', 'limit55','未涨停的昨日四板个股')
        auto_update(run)
    });

    function run(){
        get_limit1_data('get_daily_limit_performance','1', 'limit1','一板')
        get_limit1_data('get_daily_limit_performance','2', 'limit2','二板')
        get_limit2_data('get_daily_limit_performance2','2', 'limit22','未涨停的昨日一板个股')
        get_limit1_data('threePlate','2', 'limit3','三板')
        get_limit2_data('twoBoardStocksYesterday','2', 'limit33','未涨停的昨日二板个股')
        get_limit1_data('fourPlate','2', 'limit4','四板')
        get_limit2_data('threeBoardStocksYesterday','2', 'limit44','未涨停的昨日三板个股')
        get_limit1_data('fivePlate','2', 'limit5','更高')
        get_limit2_data('fourBoardStocksYesterday','2', 'limit55','未涨停的昨日四板个股')
    }
    // 获取一板涨停数据
    function get_limit1_data(fun,limit, id,caption) {
        var m_data = []
        $.ajax({
            url: '/'+fun,
            data: {'data':limit},
            type: 'POST',
            async: false,
            dataType: 'json',
            success: function(data) {
                m_data = data
                set_table1(data, id,caption)
                // set_option()
            },
            error: function(msg) {
                console.log(msg);
            }
        })
        return m_data;
    };

        // 获取昨日涨停今日未涨停数据
        function get_limit2_data(fun,limit, id,caption) {
        var m_data = []
        $.ajax({
            url: '/'+fun,
            data: {'data':limit},
            type: 'POST',
            async: false,
            dataType: 'json',
            success: function(data) {
                m_data = data
                set_table2(data, id,caption)
                // set_option()
            },
            error: function(msg) {
                console.log(msg);
            }
        })
        return m_data;
    };

    function set_table1(data, id, caption) {
        all_theme = [];
        var m_html = ""
        var m_th = "<tr class=\"cur\">\
            <th>股票名称</th>\
            <th>涨停时间</th>\
            <th>状态</th>\
            <th>涨停原因</th>\
            </tr>"
            // <th>板块</th>\
            // <th>最大封单</th>\
            // <th>封单</th>\
            // <th>主力净额</th>\
            // <th>成交额</th>\
            // <th>实际换手</th>\
            // <th>实际流通</th>\
            
        var m_list = data['data']
        for (var i_row = 0; i_row < m_list.length; i_row++) {
            if (i_row % 2 == 0) {
                m_html += "<tr>"
            } else
                m_html += "<tr class=\"cur\">"
            m_html += "<td>" + m_list[i_row][1] + "</td>"
            m_html += "<td>" + format_date(new Date(parseInt(m_list[i_row][4]) * 1000)) + "</td>"
            //     //数据统计
            // all_theme = all_theme.concat({
            //     name: m_list[i_row][5],
            //     value: 1
            // })
            m_html += "<td>" + m_list[i_row][15] + "</td>"
            m_html += "<td>" + m_list[i_row][5] + "</td>"
            // m_html += "<td>" + m_list[i_row][12] + "</td>"
            // m_html += "<td>" + format_money(m_list[i_row][7]) + "</td>"
            // m_html += "<td>" + format_money(m_list[i_row][6]) + "</td>"
            // m_html += "<td>" + format_money(m_list[i_row][8]) + "</td>"
            // m_html += "<td>" + format_money(m_list[i_row][11]) + "</td>"
            // m_html += "<td>" + m_list[i_row][14] + "</td>"
            // m_html += "<td>" + format_money(m_list[i_row][13]) + "</td>"
            m_html += "</tr>"
        }
        var tb = document.getElementById(id); //获取表格的dom节点
        var caption = "<caption align=\"top\">"+caption+"-"+m_list.length+"</caption>"  
        tb.innerHTML = caption+m_th + m_html
    }


    function set_table2(data, id,caption) {
        all_theme = [];
        var m_html = ""
        var m_th = "<tr class=\"cur\">\
            <th>股票名称</th>\
            <th>状态</th>\
            <th>板块</th>\
            <th>涨幅</th>\
            </tr>"
            // <th>成交额</th>\
        var m_list = data['data']
        for (var i_row = 0; i_row < m_list.length; i_row++) {
            if (i_row % 2 == 0) {
                m_html += "<tr>"
            } else
                m_html += "<tr class=\"cur\">"
            m_html += "<td>" + m_list[i_row][1] + "</td>"
            m_html += "<td>" + m_list[i_row][15] + "</td>"
            m_html += "<td>" + m_list[i_row][6] + "</td>"
            m_html += "<td>" + m_list[i_row][5] + "</td>"
            // m_html += "<td>" + format_money(m_list[i_row][10]) + "</td>"
            m_html += "</tr>"
        }
        var tb = document.getElementById(id); //获取表格的dom节点
        var caption = "<caption align=\"top\">"+caption+"-"+m_list.length+"</caption>"  
        tb.innerHTML = caption+m_th + m_html
    }

</script>
</html>